<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="../jquery/jquery-1.11.3.js"></script>
<link rel="stylesheet" href="../CSS/alertJob.css">
<style >
	 #In-table{
	 	border: 1;
		width:500px;
		height:50px;
		margin-top:20px;
	 }
	 blockquote{
	 	font-size:15px;
	 }
	 #check{
	 	position:fixed;
	 	width:380px;
	 	height:300px;
	 	background:#DDDDDD;
	 	top:224px;
	 	left:546px;
	 	z-index:100;
	}
	 #add{
	 	position:fixed;
	 	width:380px;
	 	height:300px;
	 	background:#DDDDDD;
	 	top:224px;
	 	left:546px;
	 	z-index:100;
	 	
	 }
	 .check-title-pic{
	 	width:100px;
	 	margin-left:351px;
	 }
	 .check-title{
		width:100%;
		height:30px;
		background:#00DDDD;
	 }
	 
	 .check-body{
	 	width:85%;
	 	height:80%;
	 	background:#DDDDDD;
	 
	 	margin-top:-11px;
	 }
	 #Content{
	 	position:relative;
	 }
	 
	  ul{
	 	height:100%;
	 	width:250px;
	 	margin-left:130px;
	 	margin-top:25px;
	 }
	  li{
	 	list-style-type:none;
	 	margin-top: 20px;
	 }
	 input{
	 	width:180px;
	 	height:20px;
	 	margin:5px 3px 5px 3px;
	 }
	 button{
	 	margin-top:10px;
	 	
	 	width:60px;
	 }
	 .text-left{
	 	
	 	font:normal 17px 微软雅黑;
	 	display: inline-block;
	 	
	 	width: 100px;
	
	 		
	 }
	 #command{
	 	position:fixed;
	 	width:500px;
	 	height:200px;
	 	background:#DDDDDD;
	 	top:100px;
	 	left:350px;
	 	z-index:100;
	 }
	  .command-title-pic{
	 	width:100px;
	 	margin-left:470px;
	 }
	 .command-title{
		width:100%;
		height:30px;
		background:#00DDDD;
	 }
	 .command-content{
	 	width:85%;
	 	height:78%;
	 	background:#DDDDDD;
	 	margin-left:44px;
	 	margin-top:-11px;
	 }
	 .text-right{
	 	font:normal 17px 微软雅黑;
	 	display: inline-block;
	 	text-align: left;
	 	width: 100px;
	 	
	 }
	  #command ul{
	 	height:100%;
	 	width:250px;
	 	margin-left:100px;
	 	margin-top:25px;
	 }
	 #command li{
	 	list-style-type:none;
	 	margin-top: 20px;
	 }
	 .text-command{
		font:normal 20px 微软雅黑;
		
	 
	 	width: 100%;
	 }
	 .button-command{
	 	margin-top: 15px;
	 	padding: 7px 13px 7px 13px;
	 	cursor: hand;
    	color: white;
    	background-color:#00DDDD;
	 	width: 65px;
	 	font: bold 15px 微软雅黑;
	 }
	 input{
	 	width: 85%;
	 }
	</style>
<title>工作岗位</title>
</head>
<body>
	<div id="Header">
		<div class="Header-Logo">
			<a href="http://www.baidu.com">
				<img src="../images/yy.png" alt="YY招聘网">
			</a>
		</div>
		<div class="Header-Logo-Right">
			<ul>
				<li>
					<a href="CompanyAllJob.html">招聘情况</a>
				</li><li>
					<a id="getCompany" href="alertJob。html" >修改岗位</a>
				</li>
			</ul>
		</div>
	</div>
	<div id="Content">
		<div class="Content-Background"></div>
		<div class="Content-Background-Content">
			<div id="Content-Title">
				<span class="Title-span">岗位编号</span>
				<span class="Title-span">岗位名称</span>
				<span class="Title-span">岗位总量</span>
				<span class="Title-span">岗位余量</span>
			</div>
			
			<div id="Main-Div" >
			</div>
			
			<div id="check" style="display: none;">
			<form id="opform1">
				<div class="check-title">
					<div class="check-title-pic">
					<a href="javascript:void(0)" onClick="closea()">
						<img width="25" height="25" alt="关闭" src="../images/maskdelete.png">
					</a> 
					</div>
				</div>
				
				<div class="check-body">
					<ul>
					<li>
						<input id="jobId" style="display: none;"/>
						<span class="text-left">岗位名称:</span>
						<input class="text-right" id="jobname" name="jobDTO.jobName"/>
						
					</li>
					<li>
						<span class="text-left">岗位容量:</span>
						<input class="text-right" id="jobnum" name="jobDTO.jobNum"/>
					</li>
					<li>
						<span class="text-left">岗位余量:</span>
						<input class="text-right" id="jobhave" name="jobDTO.jobHave"/>
					</li>
				
					<li>
						<button onClick="SendCommand()" class="AA" style="width: 150px;height: 40px;">确&nbsp;定&nbsp;修&nbsp;改</button>
					</li>
				</ul>
				</div>
			</form>
			</div>
			
			
			<div id="add" style="display: none;">
			<form id="opform2">
				<div class="check-title">
					<div class="check-title-pic">
					<a href="javascript:void(0)" onClick="closea2()">
						<img width="25" height="25" alt="关闭" src="../images/maskdelete.png">
					</a> 
					</div>
				</div>
				
				<div class="check-body">
					<ul>
					<li>
						<input id="jobcompany2" style="display: none;" />
						<span class="text-left">岗位名称:</span>
						<input class="text-right" id="jobname2" name="jobDTO.jobName"/>
						
					</li>
					<li>
						<span class="text-left">岗位容量:</span>
						<input class="text-right" id="jobnum2" name="jobDTO.jobNum"/>
					</li>
					<li>
						<span class="text-left">岗位余量:</span>
						<input class="text-right" id="jobhave2" name="jobDTO.jobHave"/>
					</li>
				
					<li>
						<button onClick="Sendsent()" class="AA" style="width: 150px;height: 40px;">确&nbsp;定&nbsp;添&nbsp;加</button>
					</li>
				</ul>
				</div>
			</form>
			</div>
			

		</div>
			<div>
			</div>
	</div>

	
	<script>
	var jobcompany=sessionStorage.comLogin;
	var jobJson;
	var Num;//获取的总数
	var totalpage;
	var currpage=1;
	var mark;//记录最后一页的数据个数
	alert(""+jobcompany);
	$.ajax({
		type : "GET",
		url: "../Resume/getCompanyJob.action?CompanyLoginName="+jobcompany,
		dataType : "json",
		success:function(data){
			jobJson = data;
			
			Num=data.num;
			alert("fsdfsdfsd +"+Num);
			
			$.makeDiv();
			
		},
		error:function(jqXHR){
			alert("发生错误： "+jqXHR.status);
		}
	});
		
		$.makeDiv=function(){
			var resumeNumber=0;
			var MainDiv=document.getElementById("Main-Div");
			for(var i=0;i<Num;i++)
			{
				resumeNumber=i+1;
				var JobId=jobJson.data[i].jobId
				var Jobname=jobJson.data[i].jobName;
				var Jobcompany=jobJson.data[i].jobCompany;
				var Jobnum=jobJson.data[i].jobNum;
				var Jobhave=jobJson.data[i].jobHave;
				
				
				var NewDiv=document.createElement("Div");
				NewDiv.className="NewDiv";
				
				var mNumber=document.createElement("span");
				var mjobname=document.createElement("span");
				//var mjobcompany=document.createElement("span");
				var mjobnum=document.createElement("span");
				var mjobhave=document.createElement("span");
				var pA=document.createElement("a");
				var pB=document.createElement("a");
				
				mNumber.className="newspan1";
				mjobname.className="newspan1";
				mjobnum.className="newspan1";
				mjobhave.className="newspan1";
				pA.className="AA";
				pB.className="AA";
				pA.innerHTML="修改";
				pB.innerHTML="删除";
				mNumber.innerHTML=resumeNumber;
				mjobname.innerHTML=Jobname;
				mjobnum.innerHTML=Jobnum;
				mjobhave.innerHTML=Jobhave;
				
				NewDiv.appendChild(mNumber);
				NewDiv.appendChild(mjobname);
				NewDiv.appendChild(mjobnum);
				NewDiv.appendChild(mjobhave);
				NewDiv.appendChild(pA);
				NewDiv.appendChild(pB);
				MainDiv.appendChild(NewDiv);
				
				pA.setAttribute("href","javascript:void(0)");
				pA.setAttribute("id",JobId+","+Jobname+","+Jobnum+","+Jobhave);
				
		
				pA.onclick=function(){
					postfunction("Jid",this.id);
				}
				
				pB.setAttribute("href","javascript:void(0)");
				pB.setAttribute("id",JobId);
				pB.onclick=function(){
					postfunction2("Jid2",this.id);
				}
			}
			
			var newDiv=document.createElement("Div");
			newDiv.className="NewDiv2";
			var pC=document.createElement("a");
			pC.className="AA2";
			pC.innerHTML="添加职位";
			newDiv.appendChild(pC);
			MainDiv.appendChild(newDiv);
			
			pC.setAttribute("href","javascript:void(0)");
			pC.setAttribute("id",Jobcompany);
			pC.onclick=function(){
					postfunction3("id3", this.id);
			}
		}
		function postfunction(name,value2){
			var mark2=value2.split(",");
			
			var Jid=mark2[0];
			var Jname=mark2[1];
			var Jnum=mark2[2];
			var Jhave=mark2[3];
			
			if(document.getElementById("check").style.display=="none"){
				document.getElementById("check").style.display="";
				document.getElementById("jobname").value=Jname;
				document.getElementById("jobnum").value=Jnum;
				document.getElementById("jobhave").value=Jhave;
				document.getElementById("jobId").value=Jid;
			}
			
		}
		function postfunction2(name,value2){
			alert(name);
			alert(value2);
			var jid=value2;
			alert(jid);
			
			var sendJson={
					"Jid":jid,
					
				};
				var request = new XMLHttpRequest();
				var type = "POST";
				var URL = "../job/deleteJob.action";
				request.open(type,URL,false);
				
				
				
				request.setRequestHeader("Content-Type","application/json");
				request.send(JSON.stringify(sendJson));	
				if(request.status === 200){
					var mark = request.getResponseHeader("Content-Type");
					if(type.indexOf("xml")!==-1 && request.responseXML){
						alert("000");
					}
					else if(type === "application/json"){						//JSON响应	
						alert("000000000");
					}
					else{														//字符串响应
						var mark = request.responseText;
						if(mark != 0){									//字符串与数字进行比较，先将字符串转换成数字，然后使用转换后值进行比较
							alert("删除成功！");
							location.href = "alertJob.html";
							//document.getElementById("check").style.display = "none";
						}
					}
				}
			
		}
		
		function postfunction3(name,value2){
			var jobcompany=value2;
			alert(jobcompany);
			
			if(document.getElementById("add").style.display=="none"){
				document.getElementById("add").style.display="";
				document.getElementById("jobcompany2").value=jobcompany;
				
			}
			
		}
		function closea(){
			if(document.getElementById("check").style.display==""){
				document.getElementById("check").style.display="none";
				
				
			}
		}
		
		
		function SendCommand(){
			alert("sfsdfsdfsadfsa4444");
			var jobid=document.getElementById("jobId").value;
			var jobname=document.getElementById("jobname").value;
			var jobnum=	document.getElementById("jobnum").value;
			var jobhave=document.getElementById("jobhave").value;
		//	var	SendState=document.getElementById("resumeDTO.resumeState").value;
		//	alert("resumeID+"+fact);
		//	alert("State+"+SendState);
			 var sendJson={
				"Jid":jobid,
				"Jname":jobname,
				"Jnum":jobnum,
				"Jhave":jobhave
			};
			var request = new XMLHttpRequest();
			var type = "POST";
			var URL = "../job/alterJob.action";
			request.open(type,URL,false);
			
			
			
			request.setRequestHeader("Content-Type","application/json");
			request.send(JSON.stringify(sendJson));	
			if(request.status === 200){
				var mark = request.getResponseHeader("Content-Type");
				if(type.indexOf("xml")!==-1 && request.responseXML){
					alert("000");
				}
				else if(type === "application/json"){						//JSON响应	
					alert("000000000");
				}
				else{														//字符串响应
					var mark = request.responseText;
					if(mark != 0){									//字符串与数字进行比较，先将字符串转换成数字，然后使用转换后值进行比较
						alert("修改成功！");
						document.getElementById("check").style.display = "none";
					}
				}
			}
			
		}
		function Sendsent(){
			alert("222");
			var jobcompany=document.getElementById("jobcompany2").value;
			var jobname=document.getElementById("jobname2").value;
			var jobnum=	document.getElementById("jobnum2").value;
			var jobhave=document.getElementById("jobhave2").value;
			 var sendJson={
				"Jname":jobname,
				"Jpany":jobcompany,
				"Jnum":jobnum,
				"Jhave":jobhave
			};
			 var request3 = new XMLHttpRequest();
				var type = "POST";
				var URL = "../job/addJob.action";
				request3.open(type,URL,false);
				
				
				
				request3.setRequestHeader("Content-Type","application/json");
				request3.send(JSON.stringify(sendJson));	
				if(request3.status === 200){
					var mark = request3.getResponseHeader("Content-Type");
					if(type.indexOf("xml")!==-1 && request.responseXML){
						alert("000");
					}
					else if(type === "application/json"){						//JSON响应	
						alert("000000000");
					}
					else{														//字符串响应
						var mark = request3.responseText;
						if(mark != 0){									//字符串与数字进行比较，先将字符串转换成数字，然后使用转换后值进行比较
							alert("添加成功！");
							document.getElementById("add").style.display = "none";
						}
					}
				}
			
		}
		console.log("afsadfsdfsdfsdfsadf");
		function closea2(){
			if(document.getElementById("add").style.display==""){
				document.getElementById("add").style.display="none";
				
				
			}
		}
		alert("dadfsdfs");
	</script>
</body>
</html>